package httpserver

import (
	"github.com/gin-gonic/gin"
	"net"
	"time"
)

type Option func(*Server)

// Port - sets the server port
func Port(port string) Option {
	return func(s *Server) {
		s.server.Addr = net.JoinHostPort("", port)
	}
}

// ReadTimeout - sets the read timeout
func ReadTimeout(timeout time.Duration) Option {
	return func(s *Server) {
		s.server.ReadTimeout = timeout
	}
}

// WriteTimeout - sets the write timeout
func WriteTimeout(timeout time.Duration) Option {
	return func(s *Server) {
		s.server.WriteTimeout = timeout
	}
}

// ShutdownTimeout - sets the shutdown timeout
func ShutdownTimeout(timeout time.Duration) Option {
	return func(s *Server) {
		s.shutdownTimeout = timeout
	}
}

// Mode - sets the Gin mode (debug, release, test)
func Mode(mode string) Option {
	return func(s *Server) {
		gin.SetMode(mode)
	}
}
